import allure

from handlers.handler_log import logger


def equal_assertion(key, actual_data: int | str, expected_data: int | str) -> int:
    result = 0
    try:
        assert actual_data == expected_data, f"相等断言失败！, '{key}' 的测试结果: '{actual_data}' != 预期结果: '{expected_data}'"
        logger.success(f"相等断言成功！, '{key}' 的测试结果: '{actual_data}' != 预期结果: '{expected_data}'")
    except AssertionError as e:
        logger.error(e)
        result = 1
        allure.attach(name="equal断言的错误内容", body=str(e), attachment_type=allure.attachment_type.TEXT)
    finally:
        return result

